package mscs.businesslogic.store;


import java.util.Date;

import mscs.data.Goods;

public class EnterStore implements IStore{
	IStoreImpl iStoreImpl = new IStoreImpl();
    @Override
	public void addGoods(Goods goods) {
		if (!iStoreImpl.verifyPerson()) {
            System.out.println("You are not allowed to do this!");
        } else if (!iStoreImpl.verifyGoods(goods)) {
            System.out.println("The goods's id is not invalid!");
        } else if (goods.getDesDate().getSeconds() < (new Date()).getSeconds()){
            System.out.println("The goods is out of date!");
        } else {
            iStoreImpl.addGoods(goods);
        }
	}

	@Override
	public boolean verifyGoods(Goods goods) {
		return iStoreImpl.verifyGoods(goods);
	}

	@Override
	public void update() {
		iStoreImpl.update();
		saveThisOperation(true);
	}

	@Override
	public void saveThisOperation(boolean in) {
		// TODO Auto-generated method stub
		iStoreImpl.saveThisOperation(in);
	}
}
